package com.sunflower.bath.common.interf.impl;

import org.framework.mybatis.Criteria;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sunflower.framework.utils.ConsoleUtils;
import org.sunflower.framework.utils.HttpUtils;
import org.sunflower.framework.utils.StringUtils;

import com.sunflower.bath.common.contants.BathContants;
import com.sunflower.bath.common.interf.IJob;
import com.sunflower.bath.common.modle.ResultMsg;
import com.sunflower.bath.model.JobNeedExecut;

public class UrlJob implements IJob {
	private final Logger logger = LoggerFactory.getLogger(getClass());
	@Override
	public ResultMsg executJob(JobNeedExecut job) {
		ResultMsg resultMsg = new ResultMsg();
		resultMsg.setIsSuccess(false);
		if(job==null||BathContants.JOB_TYPE_2!=job.getJobType()){
			logger.error("任务类型不匹配");
			resultMsg.setIsSuccess(false);
			resultMsg.setErrorCode("");
			resultMsg.setErrorMsg("任务类型不匹配");
			return resultMsg;
		}
		if(!StringUtils.isNullOrBlank(job.getJobUrl())){
			logger.error("请求路径Url为空");
			resultMsg.setIsSuccess(false);
			resultMsg.setErrorCode("");
			resultMsg.setErrorMsg("请求路径Url为空");
			return resultMsg;
		}
		String responseText = HttpUtils.GetMethod(job.getJobUrl());
		ConsoleUtils.WriteLine(responseText);
		return resultMsg;
	}
	@Override
	public ResultMsg addJob(JobNeedExecut job) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public ResultMsg updateJob(JobNeedExecut job) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public ResultMsg deleteJob(JobNeedExecut job) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public ResultMsg selectJob(Criteria<JobNeedExecut> params) {
		// TODO Auto-generated method stub
		return null;
	}

}
